require("lfs")

depth = 0

function find_file(path, node)
    depth = depth + 1
    node.subdir = {}
    for file in lfs.dir(path) do
        if file ~= "." and file ~= ".." then
            local f = path .. "/" .. file
            table.insert(node, f)
            local attr = lfs.attributes(f)
            if attr.mode == "directory" then
                local ret = find_file(f, node.subdir)
            end
        end
    end
    depth = depth -1
end

local function dump_file(node)
    if node == nil then
        return false
    end
    for k,v in ipairs(node) do
        print(k, v)
    end
    dump_file(node.subdir)
end

local node = {}
find_file("/Users/ary/workspace/lua-test", node)
dump_file(node)


